package com.zyp.test.test;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final CircleImageView circleImageView = (CircleImageView) findViewById(R.id.cv_test);
        final ImageView imageView = (ImageView) findViewById(R.id.iv_ring);
        final RotateAnimation rotateAnimation = new RotateAnimation(0,360, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        rotateAnimation.setDuration(1000);
        rotateAnimation.setInterpolator(new LinearInterpolator());
        rotateAnimation.setRepeatCount(Animation.INFINITE);
        rotateAnimation.setFillAfter(true);
        imageView.setAnimation(rotateAnimation);
        circleImageView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_UP){
                    Toast.makeText(MainActivity.this,"aaa",Toast.LENGTH_SHORT).show();
                }
                return false;
            }
        });
        circleImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(imageView.getAnimation() != null){
                    imageView.clearAnimation();
                }else {
                    imageView.startAnimation(rotateAnimation);
                }
            }
        });
        Log.d("frontTest","onCreate");
        /*circleImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<String> strings = new ArrayList<>();
                try {
                    String buf;
                    InputStream inputStream = getAssets().open("a.csv");
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                    while ((buf = bufferedReader.readLine())!=null){
                        strings.add(buf.replace("\"",""));
                    }
                    Log.d("test",strings.size()+"");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });*/
        
        /*RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        Log.d("recycler",recyclerView.toString());
        recyclerView.setAdapter(new RecyclerViewAdapter());
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));*/
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("frontTest","onStart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("frontTest","onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d("frontTest","onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d("frontTest","onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("frontTest","onDestroy");
    }

    @Override
    protected void onRestart() {
        Log.d("frontTest","onRestart");
        super.onRestart();
    }
}
